home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / mathstud.zip / FAC.M < prev    next >
Text File  |  1994-01-23  |  269b  |  16 lines

  1. function [y]=fac(n) 
  2. % y=fac(n) 
  3. % computes n factorial (demonstrate a recursive function call)
  4. % n should be a positive integer
  5.  
  6. %       S.Halevy 7/31/92
  7. %       Copyright (c) 1992 by the MathWizards
  8.  
  9. if (n<=1) 
  10.     y=n; 
  11.     return
  12. end
  13.  
  14. y=n*fac(n-1);
  15.  
  16.